<!--
 * @Author: your name
 * @Date: 2022-03-10 14:42:58
 * @LastEditTime: 2022-03-10 14:52:25
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \day10\7-AJAX-post带参.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var  xhr=new XMLHttpRequest()
        xhr.open('post','http://121.199.0.35:8888/user/login')
        let obj={
            username:'admin1',
            password:123321
        }
        //设置请求头
        xhr.setRequestHeader('Content-Type','application/json')
        xhr.send(JSON.stringify(obj))
        xhr.onreadystatechange=function(){
            if(xhr.readyState===4&xhr.status===200){
                console.log(xhr.response);
            }
        }
    </script>
</head>
<body>
    
</body>
</html>